<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Measurements</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Measurements' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">knowledge</a></li><li><a href="index.html#3">Chapter 3: Properties</a></li><li><b>Measurements</b></li></ul></div>
<p class="purpose">To define adjectives such as large, wide or roomy, which make implicit comparisons of the size of some numerical property, and which lead to comparative and superlative forms.</p>

<ul class="toc"><li><a href="3-msr.html#SP1">&#167;1. Measurements, regions and shapes</a></li><li><a href="3-msr.html#SP4">&#167;4. Creation</a></li><li><a href="3-msr.html#SP11">&#167;11. Comparative forms</a></li><li><a href="3-msr.html#SP12">&#167;12. Late registration of prepositions comparing properties</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Measurements, regions and shapes.</b>A typical example would be:
</p>

<blockquote>
    <p>Definition: A container is roomy if its carrying capacity is 10 or more.</p>
</blockquote>

<p class="commentary">Here the domain of the definition is "container", and we must assign an adjective
meaning for "roomy" which involves the comparison of a property (here "carrying
capacity") against a threshold value \(t\) (here, \(t=10\)). "roomy" is said to
be the headword; the comparative form would be roomier, and the superlative
form roomiest. The comparative will make a relation &mdash; see <a href="3-cr.html" class="internal">Comparative Relations</a> &mdash;
while and the must be a phrase. It can't be an adjective, since its domain
would be too ambiguous in text such as:
</p>

<blockquote>
    <p>if the canvas bag is roomiest, ...</p>
</blockquote>

<p class="commentary">which begs the question: roomiest out of what? All containers, or implicitly
some subcollection of them? So we avoid the problem by allowing superlatives
only when explicitly followed by a domain:
</p>

<blockquote>
    <p>roomiest container in Heathrow Terminal 5</p>
</blockquote>

<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>Each such definition allows the property value to belong to a "region", which
takes one of these three "shapes":
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MEASURE_T_OR_LESS</span><span class="plain-syntax"> -1</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">MEASURE_T_EXACTLY</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">MEASURE_T_OR_MORE</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Here are operators for checking whether we lie inside the domain, where
the LHS is the value being tested and the RHS is the constant \(t\). In weak
comparison, \(t\) itself is a member; in strict comparison, it isn't.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="function-syntax">Measurements::weak_comparison_bp</span><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> solely to placate gcc</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">MEASURE_T_OR_MORE:</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">MEASURE_T_EXACTLY:</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R_equality</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">MEASURE_T_OR_LESS:</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">default:</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"unknown region for weak comparison"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="function-syntax">Measurements::strict_comparison</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Measurements::strict_comparison</span></span>:<br/><a href="3-msr.html#SP11_1">&#167;11.1</a><br/>Measurement Adjectives - <a href="3-ma.html#SP3_3_2">&#167;3.3.2</a><br/>Comparative Relations - <a href="3-cr.html#SP6_1">&#167;6.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="comment-syntax"> solely to placate clang</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">MEASURE_T_OR_MORE:</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">MEASURE_T_OR_LESS:</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax"> = </span><span class="string-syntax">"&lt;"</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">default:</span><span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"unknown region for strict comparison"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">operator</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Creation.</b>The implementation of measurement adjectives is tricksy for reasons of
timing during Inform's run: the names of kinds, properties and values become
available at different times; whereas we need the name of the adjective
itself to become available very early on. This is why the structure below
appears to record a lot of extraneous clutter apparently needed only
temporarily during parsing &mdash; because parsing does not happen all at once,
and partial results have to be parked in the structure after one stage to
be picked up at the next.
</p>

<p class="commentary">At any rate, here goes:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">measurement_node</span><span class="plain-syntax">; </span><span class="comment-syntax"> where the actual definition is</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">headword</span><span class="plain-syntax">; </span><span class="comment-syntax"> adjective being defined (must be single word)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">adjective_meaning</span><span class="plain-syntax"> *</span><span class="identifier-syntax">headword_as_adjective</span><span class="plain-syntax">; </span><span class="comment-syntax"> which adjective meaning</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">superlative</span><span class="plain-syntax">; </span><span class="comment-syntax"> its superlative form</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop</span><span class="plain-syntax">; </span><span class="comment-syntax"> the property being compared, if any</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">name_of_property_to_compare</span><span class="plain-syntax">; </span><span class="comment-syntax"> and its name</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">region_shape</span><span class="plain-syntax">; </span><span class="comment-syntax"> one of the </span><span class="extract"><span class="extract-syntax">MEASURE_T_*</span></span><span class="comment-syntax"> constants</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">region_threshold</span><span class="plain-syntax">; </span><span class="comment-syntax"> numerical value of threshold (if any)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">region_kind</span><span class="plain-syntax">; </span><span class="comment-syntax"> of this value</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">region_threshold_evaluated</span><span class="plain-syntax">; </span><span class="comment-syntax"> have we evaluated this one yet?</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">region_threshold_text</span><span class="plain-syntax">; </span><span class="comment-syntax"> text of threshold value</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">measurement_compilation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">compilation_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure measurement_definition is accessed in 2/ins, 2/nv, 3/prp, 3/ma, 4/pp and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="function-syntax">Measurements::new</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Measurements::new</span></span>:<br/>Measurement Adjectives - <a href="3-ma.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">q</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">AW</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">THRESW</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prop</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">shape</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">PRW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">measurement_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">q</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">headword</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::first_word</span><span class="plain-syntax">(</span><span class="identifier-syntax">AW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">THRESW</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_evaluated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> = </span><span class="identifier-syntax">prop</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax"> = </span><span class="identifier-syntax">shape</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name_of_property_to_compare</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PRW</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">superlative</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">headword_as_adjective</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTAdjectives::new_measurement_compilation_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>The following converts an mdef to a property and shape:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::read_property_details</span><span class="plain-syntax">(</span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">property</span><span class="plain-syntax"> **</span><span class="identifier-syntax">prn</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> *</span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">prn</span><span class="plain-syntax">) *</span><span class="identifier-syntax">prn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">shape</span><span class="plain-syntax">) *</span><span class="identifier-syntax">shape</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>And this does the inverse, albeit a little slowly:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="function-syntax">Measurements::retrieve</span><span class="plain-syntax">(</span><span class="reserved-syntax">property</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prn</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">shape</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">, </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="3-msr.html#SP9" class="function-link"><span class="function-syntax">Measurements::validate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="3-msr.html#SP10" class="function-link"><span class="function-syntax">Measurements::is_valid</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> == </span><span class="identifier-syntax">prn</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax"> == </span><span class="identifier-syntax">shape</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>As noted above, there are timing issues here, and the initial state of a
<a href="3-msr.html#SP4" class="internal">measurement_definition</a> leaves much to be filled in later. This is called
"validation", and is to some extent performed on demand. The following tries
to validate everything:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::validate_definitions</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">, </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><a href="3-msr.html#SP9" class="function-link"><span class="function-syntax">Measurements::validate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>But we can also try to validate just one at a time:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::validate</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Measurements::validate</span></span>:<br/><a href="3-msr.html#SP7">&#167;7</a>, <a href="3-msr.html#SP8">&#167;8</a>, <a href="3-msr.html#SP11">&#167;11</a><br/>Measurement Adjectives - <a href="3-ma.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name_of_property_to_compare</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="3-msr.html#SP9_1" class="named-paragraph-link"><span class="named-paragraph">Fill in the missing property name, P</span><span class="named-paragraph-number">9.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_evaluated</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="3-msr.html#SP9_2" class="named-paragraph-link"><span class="named-paragraph">Fill in the missing threshold value, t</span><span class="named-paragraph-number">9.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9_1" class="paragraph-anchor"></a><b>&#167;9.1. </b>Here we either make \(P\) valid, or leave it <span class="extract"><span class="extract-syntax">NULL</span></span> and issue a problem.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Fill in the missing property name, P</span><span class="named-paragraph-number">9.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;property-name&gt;(mdef-&gt;</span><span class="element-syntax">name_of_property_to_compare</span><span class="plain-syntax">)) </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Validating mdef with headword %W... &lt;%W&gt;\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">headword</span><span class="plain-syntax">, </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name_of_property_to_compare</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::definition_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_GradingUnknownProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">measurement_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"that definition involves an unknown property"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"assuming it was meant to be a definition in the form 'Definition: "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"a container is large if its carrying capacity is 10 or more.'"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-msr.html#SP9">&#167;9</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP9_2" class="paragraph-anchor"></a><b>&#167;9.2. </b>Here we either make \(t\) valid, or leave <span class="extract"><span class="extract-syntax">mdef-&gt;region_threshold_evaluated</span></span> clear
and issue a problem.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Fill in the missing threshold value, t</span><span class="named-paragraph-number">9.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;s-literal&gt;(mdef-&gt;</span><span class="element-syntax">region_threshold_text</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_kind</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_kind</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_kind</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_encoded_notation</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Kinds::Behaviour::is_quasinumerical</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_kind</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax"> != </span><span class="constant-syntax">MEASURE_T_EXACTLY</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::definition_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_GradingNonarithmeticKOV</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">measurement_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the property value given here has a kind which can't be "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"subject to numerical comparisons"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"so it doesn't make sense to talk about it being 'more' or "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"'less'."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_kind</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><a href="3-vp.html#SP6" class="function-link"><span class="function-syntax">ValueProperties::kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax">)) != </span><span class="identifier-syntax">ALWAYS_MATCH</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::definition_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_GradingWrongKOV</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">measurement_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"the property value given here is the wrong kind"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"and does not match the property being looked at."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Can't get literal from &lt;%W&gt;\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_text</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::definition_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_GradingNonLiteral</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">measurement_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"that definition is wrongly phrased"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"assuming it was meant to be a grading adjective like 'Definition: a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"container is large if its carrying capacity is 10 or more.'"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_evaluated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-msr.html#SP9">&#167;9</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>To recover safely from these errors, we would be wise to check:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::is_valid</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Measurements::is_valid</span></span>:<br/><a href="3-msr.html#SP7">&#167;7</a>, <a href="3-msr.html#SP11">&#167;11</a><br/>Measurement Adjectives - <a href="3-ma.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_threshold_evaluated</span><span class="plain-syntax"> == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Comparative forms.</b>For timing reasons, these are made all at once, and later than when the headword
adjectives and superlatives are made.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::create_comparatives</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Measurements::create_comparatives</span></span>:<br/>Comparative Relations - <a href="3-cr.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">, </span><span class="reserved-syntax">measurement_definition</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="3-msr.html#SP9" class="function-link"><span class="function-syntax">Measurements::validate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><a href="3-msr.html#SP10" class="function-link"><span class="function-syntax">Measurements::is_valid</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax"> != </span><span class="constant-syntax">MEASURE_T_EXACTLY</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">H</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">headword</span><span class="plain-syntax">; </span><span class="comment-syntax"> word number of, e.g., "tall"</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">comparative_form</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Grading::make_comparative</span><span class="plain-syntax">(</span><span class="identifier-syntax">H</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">()); </span><span class="comment-syntax"> "taller than"</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">vocabulary_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">quiddity</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Grading::make_quiddity</span><span class="plain-syntax">(</span><span class="identifier-syntax">H</span><span class="plain-syntax">, </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">()))); </span><span class="comment-syntax"> "tallness"</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">i6_schema</span><span class="plain-syntax"> *</span><span class="identifier-syntax">schema_to_compare_property_values</span><span class="plain-syntax">;</span>

<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="3-msr.html#SP11_1" class="named-paragraph-link"><span class="named-paragraph">Work out property comparison schema</span><span class="named-paragraph-number">11.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="3-msr.html#SP11_2" class="named-paragraph-link"><span class="named-paragraph">Construct a BP named for the quiddity and tested using the comparative schema</span><span class="named-paragraph-number">11.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11_1" class="paragraph-anchor"></a><b>&#167;11.1. </b>This schema compares the property values:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Work out property comparison schema</span><span class="named-paragraph-number">11.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">inter_name</span><span class="plain-syntax"> *</span><span class="identifier-syntax">identifier</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTProperties::iname</span><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">operation</span><span class="plain-syntax"> = </span><a href="3-msr.html#SP3" class="function-link"><span class="function-syntax">Measurements::strict_comparison</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">schema_to_compare_property_values</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Calculus::Schemas::new</span><span class="plain-syntax">(</span><span class="string-syntax">"(*1.%n %s *2.%n)"</span><span class="plain-syntax">, </span><span class="identifier-syntax">identifier</span><span class="plain-syntax">, </span><span class="identifier-syntax">operation</span><span class="plain-syntax">, </span><span class="identifier-syntax">identifier</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-msr.html#SP11">&#167;11</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP11_2" class="paragraph-anchor"></a><b>&#167;11.2. </b>The relation arising from "tall" would be called the "tallness relation", for
instance. Note that we don't say anything about the domain of \(x\) and \(y\)
in \(T(x, y)\). That's because we a value property like "height" may exist
for more than one kind of object, and there is not necessarily any unifying
kind of value \(K\) such all objects satisfying \(K\) possess a height and all
others do not. (That's intentional: it is Inform's one concession towards
multiple-inheritance, and it allows containers and doors to share lockability
behaviour despite being of mutually incompatible kinds.)
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Construct a BP named for the quiddity and tested using the comparative schema</span><span class="named-paragraph-number">11.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">relname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">relname</span><span class="plain-syntax">, </span><span class="string-syntax">"%V"</span><span class="plain-syntax">, </span><span class="identifier-syntax">quiddity</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">bp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BinaryPredicates::make_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">property_comparison_bp_family</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BPTerms::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">), </span><span class="identifier-syntax">BPTerms::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">relname</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">schema_to_compare_property_values</span><span class="plain-syntax">, </span><span class="identifier-syntax">WordAssemblages::lit_1</span><span class="plain-syntax">(</span><span class="identifier-syntax">quiddity</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">relname</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><a href="3-cr.html#SP4" class="function-link"><span class="function-syntax">ComparativeRelations::initialise</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">bp</span><span class="plain-syntax">, </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">region_shape</span><span class="plain-syntax">, </span><span class="identifier-syntax">mdef</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">prop</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="3-msr.html#SP12" class="function-link"><span class="function-syntax">Measurements::register_comparative</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">comparative_form</span><span class="plain-syntax">, </span><span class="identifier-syntax">bp</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="3-msr.html#SP11">&#167;11</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Late registration of prepositions comparing properties.</b>The following routines, used only when all the properties have been
created, make suitable comparatives ("bigger than", etc.) and
prepositional usages to test property-equality ("the same height as").
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Measurements::register_comparative</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Measurements::register_comparative</span></span>:<br/><a href="3-msr.html#SP11_2">&#167;11.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">root</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">verb_meaning</span><span class="plain-syntax"> </span><span class="identifier-syntax">vm</span><span class="plain-syntax"> = </span><span class="identifier-syntax">VerbMeanings::regular</span><span class="plain-syntax">(</span><span class="identifier-syntax">root</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">preposition</span><span class="plain-syntax"> *</span><span class="identifier-syntax">prep</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Prepositions::make</span><span class="plain-syntax">(</span><span class="identifier-syntax">PreformUtilities::merge</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;comparative-property-construction&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WordAssemblages::lit_1</span><span class="plain-syntax">(</span><span class="identifier-syntax">Lexer::word</span><span class="plain-syntax">(</span><span class="identifier-syntax">Wordings::first_wn</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)))),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Verbs::add_form</span><span class="plain-syntax">(</span><span class="identifier-syntax">copular_verb</span><span class="plain-syntax">, </span><span class="identifier-syntax">prep</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">vm</span><span class="plain-syntax">, </span><span class="identifier-syntax">SVO_FS_BIT</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. </b>When the source text creates a measurement adjective such as "tall", the
following is used to construct the comparative form, "taller than":
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;comparative-property-construction&gt;</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">than</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="3-spr2.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-km.html">1</a></li><li class="progresschapter"><a href="2-ins.html">2</a></li><li class="progresscurrentchapter">3</li><li class="progresssection"><a href="3-prp.html">prp</a></li><li class="progresssection"><a href="3-ep.html">ep</a></li><li class="progresssection"><a href="3-epa.html">epa</a></li><li class="progresssection"><a href="3-vp.html">vp</a></li><li class="progresssection"><a href="3-tpr.html">tpr</a></li><li class="progresssection"><a href="3-spr.html">spr</a></li><li class="progresssection"><a href="3-spr2.html">spr2</a></li><li class="progresscurrent">msr</li><li class="progresssection"><a href="3-ma.html">ma</a></li><li class="progresssection"><a href="3-cr.html">cr</a></li><li class="progresschapter"><a href="4-is.html">4</a></li><li class="progresschapter"><a href="5-inf.html">5</a></li><li class="progressnext"><a href="3-ma.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

